/*
 * @(#) JobAction.java 2011-9-7
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.system.presentation.action;

import java.util.List;

import cn.strong.gweva.common.business.entity.PagerEntity;
import cn.strong.gweva.common.business.entity.db.JxkhJobEntity;
import cn.strong.gweva.common.presentation.action.AjaxBaseAction;
import cn.strong.gweva.system.business.entity.JobSearchEntity;
import cn.strong.gweva.system.business.service.JobService;


/**
 * 岗位管理Action.
 * 
 * @author jincong
 * @version 1.0
 * @since 2011-9-7
 */
public class JobAction extends AjaxBaseAction
{

	/** serialVersionUID */
	private static final long serialVersionUID = 1999448294212812899L;

	/** 岗位 */
	private JxkhJobEntity job;

	/** 岗位列表 */
	private List<JxkhJobEntity> jobList;

	/** 岗位管理service */
	private JobService jobService;

	/** 岗位检索结果（分页） */
	private PagerEntity pagerEntity;

	/** 岗位管理检索条件 */
	private JobSearchEntity jobSearchEntity;

	/**
	 * 新增岗位初始化.
	 * 
	 * @return
	 */
	public String add()
	{
		return ADD;
	}

	/**
	 * 新增岗位.
	 * 
	 * @return
	 */
	public String insert()
	{

		try
		{

			this.job.setUpdateUserId(this.getLoginUser().getUserId());
			this.jobService.insert(this.job);
		}
		catch (Exception e)
		{
			return processException(e);
		}

		return this.list();
	}

	/**
	 * 修改岗位初始化.
	 * 
	 * @return
	 */
	public String modify()
	{
		try
		{

			this.job = this.jobService.searchJobById(this.job);
		}
		catch (Exception e)
		{
			return processException(e);
		}

		return MODIFY;
	}

	/**
	 * 修改岗位.
	 * 
	 * @return
	 */
	public String update()
	{
		try
		{

			this.job.setUpdateUserId(this.getLoginUser().getUserId());
			this.jobService.update(this.job);
		}
		catch (Exception e)
		{
			return processException(e);
		}

		return this.list();
	}

	/**
	 * 删除岗位.
	 * 
	 * @return
	 */
	public String delete()
	{
		try
		{

			this.job.setUpdateUserId(this.getLoginUser().getUserId());
			this.jobService.delete(this.job);
		}
		catch (Exception e)
		{
			return processException(e);
		}

		return this.list();
	}

	/**
	 * 岗位列表.
	 * 
	 * @return
	 */
	public String list()
	{

		try
		{
			this.pagerEntity = this.jobService
					.searchJobPage(this.pagerEntity, this.jobSearchEntity);
		}
		catch (Exception e)
		{
			return processException(e);
		}

		return LIST;
	}

	/**
	 * 设定岗位.
	 * 
	 * @param job 岗位
	 */
	public void setJob(JxkhJobEntity job)
	{
		this.job = job;
	}

	/**
	 * 获取岗位.
	 * 
	 * @return 岗位
	 */
	public JxkhJobEntity getJob()
	{
		return this.job;
	}

	/**
	 * 设定岗位列表.
	 * 
	 * @param jobList 岗位列表
	 */
	public void setJobList(List<JxkhJobEntity> jobList)
	{
		this.jobList = jobList;
	}

	/**
	 * 获取岗位列表.
	 * 
	 * @return 岗位列表
	 */
	public List<JxkhJobEntity> getJobList()
	{
		return this.jobList;
	}

	/**
	 * 设定岗位管理service.
	 * 
	 * @param jobService 岗位管理service
	 */
	public void setJobService(JobService jobService)
	{
		this.jobService = jobService;
	}

	/**
	 * 设定岗位管理检索条件.
	 * 
	 * @param jobSearchEntity 岗位管理检索条件
	 */
	public void setJobSearchEntity(JobSearchEntity jobSearchEntity)
	{
		this.jobSearchEntity = jobSearchEntity;
	}

	/**
	 * 获取岗位管理检索条件.
	 * 
	 * @return 岗位管理检索条件
	 */
	public JobSearchEntity getJobSearchEntity()
	{
		return this.jobSearchEntity;
	}

	/**
	 * 设定岗位检索结果（分页）.
	 * 
	 * @param pagerEntity 岗位检索结果（分页）
	 */
	public void setPagerEntity(PagerEntity pagerEntity)
	{
		this.pagerEntity = pagerEntity;
	}

	/**
	 * 获取岗位检索结果（分页）.
	 * 
	 * @return 岗位检索结果（分页）
	 */
	public PagerEntity getPagerEntity()
	{
		return this.pagerEntity;
	}

}
